package com.dominator.repository;

import com.dominFramework.core.dao.SqlDao;
import com.dominFramework.core.typewrap.Dto;
import com.dominator.mybatis.dao.T_qr_lottery_ticketDao;
import com.dominator.mybatis.dao.T_qr_lottery_ticketPO;
import com.dominator.utils.dao.JdbcHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.util.List;

@Repository
public class DaoQrLotteryTicket {
    @Resource
    JdbcHelper jh;

    @Autowired
    SqlDao sqlDao;


    @Autowired
    T_qr_lottery_ticketDao t_qr_lottery_ticketDao;


    /**
     * 添加
     *
     * @param
     * @return
     */
    public Integer batchInsert(List<Dto> list) {
        return sqlDao.insert("QrLottery.batchInsert", list);
    }


    /**
     * 根据商户查询余票
     *
     * @param
     * @return
     */
    public Integer countTicketByMerchantId(Dto dto) {
        return (Integer) sqlDao.selectOne("QrLottery.countTicketByMerchantId", dto);
    }


    /**
     * 查询单张票
     *
     * @param
     * @return
     */
    public T_qr_lottery_ticketPO selectOneByMerchantId(Dto dto) {
        return (T_qr_lottery_ticketPO) sqlDao.selectOne("QrLottery.selectOneByMerchantId", dto);
    }


    /**
     * 查询已使用的票列表
     *
     * @return
     */
    public List<T_qr_lottery_ticketPO> selectUsedTicket() {
        return sqlDao.list("QrLottery.selectUsedTicket", null);
    }

    /**
     * 查询用户使用情况
     * @return
     */
    public List<Dto> selectUserTickets() {
        return sqlDao.list("QrLottery.selectUserTickets", null);
    }


    /**
     * 获取合作伙伴手机号
     * @return
     */
    public String selectPartnerPhoneNum(){
        return (String) sqlDao.selectOne("QrLottery.selectPartnerPhoneNum", null);
    }

}
